from orders.models import OrderInfo, OrderGoods
from rest_framework import serializers
from goods.models import SKU


class SKUSerializer(serializers.ModelSerializer):
    class Meta:
        model = SKU
        fields = ('name', 'default_image_url')


class OrderGoodsSerializer(serializers.ModelSerializer):
    sku = SKUSerializer(read_only=True)

    class Meta:
        model = OrderGoods
        fields = ('sku', 'count', 'price',)


class OrderInfoSerializer(serializers.ModelSerializer):
    skus = OrderGoodsSerializer(read_only=True, many=True)

    class Meta:
        model = OrderInfo
        fields = "__all__"
